package org.csu.leiyun.spring.demo.aop.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class ProxyDemo implements InvocationHandler {
    private Object object;
    public ProxyDemo(Object object){
        this.object=object;
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { //自定义代理
        if(method.getName().equals("find")){
            beforeAdvice();
        }
        Object proxyObject = method.invoke(object,args);
        return proxyObject;//执行自己的代理
    }
    public void beforeAdvice(){
        System.out.println("前置建议:日志记录。。。。");
    }
}
